home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
System Booster
/
System Booster.iso
/
Systemmonitors
/
LastGURU
/
LastGURU.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-09-26
|
16KB
|
447 lines
/*
* LastGURU
* ¯¯¯¯¯¯¯¯
* Based on Olaf Barthel's "LastAlert"
*
* © 1996 by Timo C. Nentwig
* All Rights Reserved
*
* Tcn@techbase.in-berlin.de
*
*
* Purpose
* ¯¯¯¯¯¯¯
* Simple program that opens a gtlayout window
* and displays infomation about the last GURU
*
*/
#include <exec/execbase.h>
#include <exec/alerts.h>
#include <proto/exec.h>
#include <libraries/gtlayout.h>
#include <stdio.h>
#define PRG_TITLE "LastGURU"
#define PRG_VERSION "1.0"
#define PRG_AUTHOR "Timo C. Nentwig"
#define PRG_EMAIL "Tcn@techbase.in-berlin.de"
enum { ID_GAD = 10, ID_MEN_QUIT = 20 };
GLOBAL struct ExecBase *SysBase;
STATIC BYTE __ver[] = "$VER: "PRG_TITLE" "PRG_VERSION" "__AMIGADATE__;
STRPTR GetDeclare (ULONG ID, struct AlertInfo *List, BYTE ShowTraps);
struct AlertInfo
{
ULONG ID;
STRPTR Text;
};
struct AlertInfo CauseList[] =
{
AG_NoMemory, "Not enough memory",
AG_MakeLib, "Library initialization failed",
AG_OpenLib, "Library failed to open",
AG_OpenDev, "Device failed to open",
AG_OpenRes, "Resource failed to open",
AG_IOError, "I/O error",
AG_NoSignal, "AllocSignal () failed",
AG_BadParm, "Bad parameters",
AG_CloseLib, "Invalid request to close library",
AG_CloseDev, "Invalid request to close device",
AG_ProcCreate, "Process creation failed",
NULL, NULL
};
struct AlertInfo ObjectList[] =
{
AO_ExecLib, "exec.library",
AO_GraphicsLib, "graphics.library",
AO_LayersLib, "layers.library",
AO_Intuition, "intuition.library",
AO_MathLib, "math???.library",
AO_DOSLib, "dos.library",
AO_RAMLib, "ram.library",
AO_IconLib, "icon.library",
AO_ExpansionLib, "expansion.library",
AO_DiskfontLib, "diskfont.library",
AO_UtilityLib, "utility.library",
AO_AudioDev, "audio.device",
AO_ConsoleDev, "console.device",
AO_GamePortDev, "gameport.device",
AO_KeyboardDev, "keyboard.device",
AO_TrackDiskDev, "trackdisk.device",
AO_TimerDev, "timer.device",
AO_CIARsrc, "cia.resource",
AO_DiskRsrc, "disk.resource",
AO_MiscRsrc, "misc.resource",
AO_BootStrap, "BootStrap",
AO_Workbench, "Workbench",
AO_DiskCopy, "DiskCopy",
AO_GadTools, "gadtools.library",
AO_Unknown, "Unknown",
NULL, NULL
};
struct AlertInfo DescriptionList[] =
{
AN_ExecLib, "exec.library",
AN_ExcptVect, "680x0 exception vector checksum corrupt",
AN_BaseChkSum, "ExecBase checksum corrupt",
AN_LibChkSum, "Library checksum corrupt",
AN_MemCorrupt, "Corrupt memory list detected in FreeMem",
AN_IntrMem, "No memory for interrupt servers",
AN_InitAPtr, "InitStruct () of an APTR source",
AN_SemCorrupt, "A semaphore is in an illegal state at ReleaseSempahore ()",
AN_FreeTwice, "Freeing memory already freed",
AN_BogusExcpt, "Illegal 680x0 exception taken",
AN_IOUsedTwice, "Attempt to reuse active IORequest",
AN_MemoryInsane, "Sanity check on memory list failed during AvailMem (MEMF_LARGEST)",
AN_IOAfterClose, "I/O attempted on closed IORequest",
AN_StackProbe, "Stack appears to extend out of range",
AN_BadFreeAddr, "Memory header not located, usually an invalid address passed to FreeMem ()",
AN_GraphicsLib, "graphics.library",
AN_GfxNoMem, "graphics.library out of memory",
AN_GfxNoMemMspc, "Not enough memory for MonitorSpec",
AN_LongFrame, "Not enough memory for long frame copper list",
AN_ShortFrame, "Not enough memory for short frame copper list",
AN_TextTmpRas, "Not enough memory for text rendering",
AN_BltBitMap, "Not enough memory for BltBitMap ()",
AN_RegionMemory, "Not enough memory for clip regions",
AN_MakeVPort, "Not enough memory for MakeVPort ()",
AN_GfxNewError, "Memory allocation error",
AN_GfxFreeError, "Memory deallocation error",
AN_GfxNoLCM, "Emergency memory not available",
AN_ObsoleteFont, "Unsupported font description used",
AN_LayersLib, "layers.library",
AN_LayersNoMem, "layers.library ran out of memory",
AN_Intuition, "intuition.library",
AN_GadgetType, "Unknown gadget type",
AN_BadGadget, "Unknown gadget type",
AN_CreatePort, "MsgPort creation failed",
AN_ItemAlloc, "MenuItem plane allocation failed",
AN_SubAlloc, "MenuSubItem allocation failed",
AN_PlaneAlloc, "Plane allocation failed",
AN_ItemBoxTop, "Item box top < RelZero",
AN_OpenScreen, "Not enough memory to open screen",
AN_OpenScrnRast, "Not enough memory to open screen",
AN_SysScrnType, "Unknown system screen type",
AN_AddSWGadget, "Not enough memory to add gadgets",
AN_OpenWindow, "Not enough memory to open window",
AN_BadState, "Bad State Return entering Intuition ()",
AN_BadMessage, "Bad Message received by IDCMP",
AN_WeirdEcho, "Weird echo causing incomprehension",
AN_NoConsole, "Couldn't open the Console Device",
AN_MathLib, "math???.library",
AN_DOSLib, "dos.library",
AN_StartMem, "Not enough memory at startup",
AN_EndTask, "EndTask () didn't terminate process",
AN_QPktFail, "QueuePacket () failed",
AN_AsyncPkt, "Unexpected packet received",
AN_FreeVec, "FreeVec () failed",
AN_DiskBlkSeq, "Disk block sequence error",
AN_BitMap, "Bitmap corrupt",
AN_KeyFree, "Key already free",
AN_BadChkSum, "Invalid checksum",
AN_DiskError, "Disk Error",
AN_KeyRange, "Key out of range",
AN_BadOverlay, "Bad overlay",
AN_BadInitFunc, "Invalid initialization packet for CLI/Shell",
AN_FileReclosed, "A filehandle was closed more than once",
AN_RAMLib, "ram.library",
AN_BadSegList, "Overlay detected in library seglist",
AN_IconLib, "icon.library",
AN_ExpansionLib, "expansion.library",
AN_BadExpansionFree, "Freed free region",
AN_DiskfontLib, "diskfont.library",
AN_AudioDev, "audio.device",
AN_ConsoleDev, "console.device",
AN_NoWindow, "Console can't open window",
AN_GamePortDev, "gameport.device",
AN_KeyboardDev, "keyboard.device",
AN_TrackDiskDev, "trackdisk.device",
AN_TDCalibSeek, "Seek error during calibration",
AN_TDDelay, "Error on timer wait",
AN_TimerDev, "timer.device",
AN_TMBadReq, "Bad timerequest",
AN_TMBadSupply, "Bad power supply",
AN_CIARsrc, "cia.resource",
AN_DiskRsrc, "disk.resource",
AN_DRHasDisk, "GetUnit () already has disk",
AN_DRIntNoAct, "No active unit for interrupt",
AN_MiscRsrc, "misc.resource",
AN_BootStrap, "bootstrap",
AN_BootError, "Boot code returned an error",
AN_Workbench, "Workbench",
AN_DiskCopy, "DiskCopy",
AN_GadTools, "gadtools.library",
AN_UtilityLib, "utility.library",
AN_Unknown, "Unknown",
0x00000002, "Bus error",
0x00000003, "Bad aligned address",
0x00000005, "Division by zero",
0x00000006, "Check instruction",
0x00000007, "Trap instruction",
0x00000008, "Privilege violation",
0x00000009, "Trace mode",
0x0000000A, "LineA emulation",
0x0000000B, "Bus error",
0x0000000D, "Coprocessor protocol violation",
0x0000000E, "Format error",
0x80000002, "Bus error",
0x80000003, "Bad aligned address",
0x80000005, "Division by zero",
0x80000006, "Check instruction",
0x80000007, "Trap instruction",
0x80000008, "Privilege violation",
0x80000009, "Trace mode",
0x8000000A, "LineA emulation",
0x8000000B, "Bus error",
0x8000000D, "Coprocessor protocol violation",
0x8000000E, "Format error",
NULL, NULL,
};
/// main ()
VOID
main (UWORD argc, STRPTR argv[])
{
// at least OS2 is required
if (!SysBase || SysBase -> LibNode.lib_Version < 37)
{
printf (PRG_TITLE" requires at least AmigaOS v37\n");
}
else
{
if (*argv[1] == '?')
{
printf ("");
printf (PRG_TITLE" "PRG_VERSION" ("__AMIGADATE__")\n");
printf ("© 1996 by "PRG_AUTHOR"\n");
printf ("");
printf ("all rights reserved\n");
printf ("\n");
printf (PRG_EMAIL"\n");
}
else
{
struct GTLayoutBase *GTLayoutBase;
if (NULL != (GTLayoutBase = (struct GTLayoutBase *) OpenLibrary ("gtlayout.library", 0)))
{
struct LayoutHandle *handle;
ULONG *GuruData = (ULONG *) 0x0100;
ULONG Guru;
ULONG Task;
STRPTR lab_list[7];
STRPTR gad_list[7];
if (! (Guru = GuruData[0]))
{
Guru = SysBase -> LastAlert[0];
Task = SysBase -> LastAlert[1];
}
else
Task = GuruData[1];
{
UBYTE tmp_guru[10];
UBYTE tmp_task[10];
sprintf (tmp_guru, "$%08X", Guru);
sprintf (tmp_task, "$%08X", Task);
gad_list[0] = tmp_guru;
gad_list[1] = tmp_task;
gad_list[2] = (Guru & AT_DeadEnd) ? "Dead end alert" : "Recoverable alert";
gad_list[3] = GetDeclare (Guru & 0x000F0000, CauseList, FALSE);
gad_list[4] = GetDeclare (Guru & 0x0000F00F, ObjectList, FALSE);
gad_list[5] = GetDeclare (Guru, DescriptionList, FALSE);
gad_list[6] = NULL;
lab_list[0] = "Number";
lab_list[1] = "Task";
lab_list[2] = "Type";
lab_list[3] = "Cause";
lab_list[4] = "Object";
lab_list[5] = "Description";
lab_list[6] = NULL;
}
if (handle = LT_CreateHandleTags (NULL, TAG_END))
{
struct Window *win;
LT_New (handle, LA_Type, VERTICAL_KIND,
LA_LabelText, PRG_TITLE,
TAG_END);
{
UWORD i;
for (i = 0; i < 6; i++)
{
LT_New (handle, LA_Type, TEXT_KIND,
LA_ID, ID_GAD + i,
LA_HighLabel, TRUE,
LA_LabelText, lab_list[i],
GTTX_Text, gad_list[i],
GTTX_Border, TRUE,
TAG_END);
if (i == 1 || i == 2)
{
LT_New (handle, LA_Type, XBAR_KIND,
TAG_END);
}
}
LT_EndGroup (handle);
}
if (win = LT_Build (handle, LAWN_Title, PRG_TITLE" "PRG_VERSION,
LAWN_IDCMP, IDCMP_CLOSEWINDOW,
LAWN_AutoRefresh, TRUE,
LAWN_Zoom, TRUE,
WA_CloseGadget, TRUE,
WA_DepthGadget, TRUE,
WA_DragBar, TRUE,
WA_RMBTrap, TRUE,
TAG_END))
{
struct IntuiMessage *Msg;
BOOL done = FALSE;
REGISTER ULONG MsgClass;
REGISTER UWORD MsgCode;
while (done == FALSE)
{
while (Msg = LT_GetIMsg (handle))
{
MsgClass = Msg -> Class;
MsgCode = Msg -> Code;
LT_ReplyIMsg (Msg);
switch (MsgClass)
{
case IDCMP_CLOSEWINDOW:
done = TRUE;
break;
}
}
}
}
LT_DeleteHandle (handle);
}
CloseLibrary ((struct Library *) GTLayoutBase);
}
}
}
}
///
/// GetDeclare ()
/*
* FUNCTION Picks the text for given ID
*
* NOTE
*
* EXAMPLE GetDeclare (Guru & 0x000F0000, CauseList, FALSE);
*
*/
STRPTR
GetDeclare (ULONG ID, struct AlertInfo *List, BYTE ShowTraps)
{
LONG i;
for (i = 0; List[i].Text; i++)
{
if (ID == List[i].ID)
return (List[i].Text);
}
if (ShowTraps)
{
STATIC UBYTE Buffer[20];
if ( (ID & ~0x80000000))
{
sprintf (Buffer, "Trap #%d", ID & ~0x80000000);
return (Buffer);
}
}
return ("Not specified");
}
///